package mastermanagment.view;

import java.awt.event.ActionListener;

import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JTextField;
import javax.swing.JSeparator;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JButton;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.border.BevelBorder;
import javax.swing.UIManager;

public class EmployeeInfoView extends JPanel
{
	private JButton[] buttongrp=new JButton[6];	
	private JTextField tfEmployeeId;
	private JTextField tfName;
	private JTextField tfjoiningDate;
	private JTextField tfDesignation;
	private JTextField tfleftDate;
	private JTextField tfPhone;
	private JTextArea textAreaAddr;
	private JButton btnStatus;
	private JButton btnSave;
	private JButton btnClear;
	private JButton btnUpdate;
	private JButton btnBack;
	private JButton btnSearch;
	private JButton btnForward;
	private JLabel lblActive;
	public EmployeeInfoView() 
	{
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		this.setBackground(new Color(239,239,239));
	    this.setPreferredSize(new Dimension(360, 641));
		
		/*
		 * SETTING LABELS
		 */
		 String[] labelsTitle = {"Name: ", "Phone: ", "Email: ", "Address: "};
		 JLabel[] labels=new JLabel[4];
		 
		 for(int i=0;i<labels.length;i++)
		 {
			 labels[i]=new JLabel(labelsTitle[i], JLabel.TRAILING);
			 add(labels[i]);
		 }
		
		tfEmployeeId = new JTextField();
		tfEmployeeId.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		tfEmployeeId.setEditable(false);
		springLayout.putConstraint(SpringLayout.NORTH, tfEmployeeId, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.EAST, tfEmployeeId, -30, SpringLayout.EAST,this);
		add(tfEmployeeId);
		tfEmployeeId.setVisible(false);
		tfEmployeeId.setColumns(10);
		
		JLabel lblEmployeeId = new JLabel("Employee Id :");
		lblEmployeeId.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, lblEmployeeId, 10, SpringLayout.NORTH,this);
		springLayout.putConstraint(SpringLayout.EAST, lblEmployeeId, -6, SpringLayout.WEST, tfEmployeeId);
		add(lblEmployeeId);
		
		JLabel lblEmpName = new JLabel("Employee Name");
		lblEmpName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblEmpName, 20, SpringLayout.SOUTH,lblEmployeeId);
		springLayout.putConstraint(SpringLayout.WEST, lblEmpName, 30, SpringLayout.WEST, this);
		add(lblEmpName);
		
		tfName = new JTextField();
		tfName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, tfName, 6, SpringLayout.SOUTH, lblEmpName);
		springLayout.putConstraint(SpringLayout.EAST, tfEmployeeId, 0, SpringLayout.EAST,tfName);
		springLayout.putConstraint(SpringLayout.WEST, tfName, 30, SpringLayout.WEST,this);
		add(tfName);
		tfName.setPreferredSize(new Dimension(300, 23));
		
		JLabel lblEmployeeDesignation = new JLabel("Employee Designation");
		springLayout.putConstraint(SpringLayout.NORTH, lblEmployeeDesignation, 15, SpringLayout.SOUTH, tfName);
		springLayout.putConstraint(SpringLayout.WEST, lblEmployeeDesignation, 30, SpringLayout.WEST,this);
		lblEmployeeDesignation.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(lblEmployeeDesignation);
		
		tfDesignation = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tfDesignation, 6, SpringLayout.SOUTH, lblEmployeeDesignation);
		springLayout.putConstraint(SpringLayout.WEST, tfDesignation, 30, SpringLayout.WEST,this);
		tfDesignation.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(tfDesignation);
		tfDesignation.setColumns(10);
		
		JLabel lblJoinedDate = new JLabel("Joining Date");
		springLayout.putConstraint(SpringLayout.NORTH, lblJoinedDate, 15, SpringLayout.SOUTH, tfDesignation);
		springLayout.putConstraint(SpringLayout.WEST, lblJoinedDate, 30, SpringLayout.WEST,this);
		lblJoinedDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(lblJoinedDate);
		
		tfjoiningDate = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tfjoiningDate, 6, SpringLayout.SOUTH, lblJoinedDate);
		springLayout.putConstraint(SpringLayout.WEST, tfjoiningDate, 30, SpringLayout.WEST, this);
		tfjoiningDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(tfjoiningDate);
		tfjoiningDate.setColumns(10);
		
		JLabel lblLeftDate = new JLabel("Left Date");
		springLayout.putConstraint(SpringLayout.NORTH, lblLeftDate, 15, SpringLayout.SOUTH, tfjoiningDate);
		springLayout.putConstraint(SpringLayout.WEST, lblLeftDate, 30, SpringLayout.WEST, this);
		lblLeftDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(lblLeftDate);
		
		tfleftDate = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tfleftDate, 6, SpringLayout.SOUTH, lblLeftDate);
		springLayout.putConstraint(SpringLayout.WEST, tfleftDate, 30, SpringLayout.WEST, this);
		tfleftDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(tfleftDate);
		tfleftDate.setColumns(10);
		
		JLabel lblPhoneNo = new JLabel("Phone No");
		springLayout.putConstraint(SpringLayout.NORTH, lblPhoneNo, 15, SpringLayout.SOUTH,tfleftDate);
		springLayout.putConstraint(SpringLayout.WEST, lblPhoneNo, 30, SpringLayout.WEST,this);
		lblPhoneNo.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(lblPhoneNo);
		
		tfPhone = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tfPhone, 6, SpringLayout.SOUTH, lblPhoneNo);
		springLayout.putConstraint(SpringLayout.WEST, tfPhone, 30, SpringLayout.WEST,this);
		tfPhone.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(tfPhone);
		tfPhone.setColumns(10);
		
		JLabel lblAddress = new JLabel("Address");
		springLayout.putConstraint(SpringLayout.NORTH, lblAddress, 15, SpringLayout.SOUTH,tfPhone);
		springLayout.putConstraint(SpringLayout.WEST, lblAddress, 30, SpringLayout.WEST, this);
		lblAddress.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(lblAddress);
		
		textAreaAddr = new JTextArea();
		textAreaAddr.setPreferredSize(new Dimension(300, 23));
		textAreaAddr.setRows(3);
		springLayout.putConstraint(SpringLayout.NORTH,textAreaAddr, 6, SpringLayout.SOUTH,lblAddress);
		springLayout.putConstraint(SpringLayout.WEST, textAreaAddr, 30, SpringLayout.WEST, this);
		add(textAreaAddr);
		
		btnStatus = new JButton("Mark Inactive");
		btnStatus.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH,btnStatus, 15, SpringLayout.SOUTH,textAreaAddr);
		springLayout.putConstraint(SpringLayout.WEST,btnStatus, 30, SpringLayout.WEST, this);
		add(btnStatus);
		
		JPanel panel = new JPanel();
		springLayout.putConstraint(SpringLayout.NORTH, panel,15, SpringLayout.SOUTH,btnStatus);
		springLayout.putConstraint(SpringLayout.WEST, panel, 30, SpringLayout.WEST,this);
		add(panel);
		panel.setPreferredSize(new Dimension(300, 120));
		GridLayout g=new GridLayout(2,3,2,2);
		panel.setLayout(g);

		btnSave = new JButton("SAVE  ");
		btnSave.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		btnSave.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnSave);
		btnSave.setActionCommand("SAVE");
		buttongrp[0]=btnSave;
		
		btnClear = new JButton("CLEAR ");
		btnClear.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnClear);
		btnClear.setActionCommand("CLEAR");
		buttongrp[6]=btnClear;
		
		btnUpdate = new JButton("UPDATE");
		btnUpdate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnUpdate);
		btnUpdate.setActionCommand("UPDATE");
		buttongrp[2]=btnUpdate;
		
		btnBack = new JButton("  <<  ");
		btnBack.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnBack);
		btnBack.setActionCommand("<< ");
		buttongrp[3]=btnBack;
		
		btnSearch = new JButton("SEARCH");
		btnSearch.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnSearch);
		btnSearch.setActionCommand("SEARCH");
		buttongrp[4]=btnSearch;
		
		btnForward = new JButton(">>");
		btnForward.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnForward);
		btnForward.setActionCommand(">>");
		buttongrp[5]=btnForward;
		
	}
	
	
	


	public JButton[] getButtongrp() {
		return buttongrp;
	}





	public void setButtongrp(JButton[] buttongrp) {
		this.buttongrp = buttongrp;
	}





	public JTextField getTfEmployeeId() {
		return tfEmployeeId;
	}





	public void setTfEmployeeId(JTextField tfEmployeeId) {
		this.tfEmployeeId = tfEmployeeId;
	}





	public JTextField getTfName() {
		return tfName;
	}





	public void setTfName(JTextField tfName) {
		this.tfName = tfName;
	}





	public JTextField getTfjoiningDate() {
		return tfjoiningDate;
	}





	public void setTfjoiningDate(JTextField tfjoiningDate) {
		this.tfjoiningDate = tfjoiningDate;
	}





	public JTextField getTfDesignation() {
		return tfDesignation;
	}





	public void setTfDesignation(JTextField tfDesignation) {
		this.tfDesignation = tfDesignation;
	}





	public JTextField getTfleftDate() {
		return tfleftDate;
	}





	public void setTfleftDate(JTextField tfleftDate) {
		this.tfleftDate = tfleftDate;
	}





	public JTextField getTfPhone() {
		return tfPhone;
	}





	public void setTfPhone(JTextField tfPhone) {
		this.tfPhone = tfPhone;
	}





	public JTextArea getTextAreaAddr() {
		return textAreaAddr;
	}





	public void setTextAreaAddr(JTextArea textAreaAddr) {
		this.textAreaAddr = textAreaAddr;
	}





	public JButton getBtnStatus() {
		return btnStatus;
	}





	public void setBtnStatus(JButton btnStatus) {
		this.btnStatus = btnStatus;
	}





	public JButton getBtnSave() {
		return btnSave;
	}





	public void setBtnSave(JButton btnSave) {
		this.btnSave = btnSave;
	}





	public JButton getBtnClear() {
		return btnClear;
	}





	public void setBtnClear(JButton btnClear) {
		this.btnClear = btnClear;
	}





	public JButton getBtnUpdate() {
		return btnUpdate;
	}





	public JLabel getLblActive() {
		return lblActive;
	}





	public void setLblActive(JLabel lblActive) {
		this.lblActive = lblActive;
	}





	public void setBtnUpdate(JButton btnUpdate) {
		this.btnUpdate = btnUpdate;
	}





	public JButton getBtnBack() {
		return btnBack;
	}





	public void setBtnBack(JButton btnBack) {
		this.btnBack = btnBack;
	}





	public JButton getBtnSearch() {
		return btnSearch;
	}





	public void setBtnSearch(JButton btnSearch) {
		this.btnSearch = btnSearch;
	}





	public JButton getBtnForward() {
		return btnForward;
	}





	public void setBtnForward(JButton btnForward) {
		this.btnForward = btnForward;
	}





	public void actionListener(ActionListener al)
	{
		
		for(int i=0;i<buttongrp.length;i++)
		{
			buttongrp[i].addActionListener(al);
		}
	}
}
